<template>
  <div id="app">
    <h2>测试题</h2>
    <div>
      <MySubject
        v-for="(item, index) in arr"
        :key="index"
        :obj="item"
        @tijiao="item.result = $event"
      ></MySubject>
    </div>
    <div>
      <MyTag
        v-for="(item, index) in arr"
        :key="index"
        :obj="item"
        :index="index"
      ></MyTag>
    </div>
  </div>
</template>

<script>
import MySubject from "@/components/MySubject.vue";
import MyTag from "@/components/MyTag.vue";
export default {
  created() {
    const arr = [];
    for (let i = 0; i < 5; i++) {
      const left = Math.floor(Math.random() * 11);
      const right = Math.floor(Math.random() * 11);
      arr.push({ left, right, result: null });
    }
    this.arr = arr;
  },
  components: {
    MySubject,
    MyTag,
  },
  data() {
    return {
      arr: [],
    };
  },
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>
